package bairui.international.model.domain.jpa;

import com.lianjing.sh.model.uml.model.file.TBSuper_FileBase;

/**
 *
 * (奖品)TB_PrizeItem
 *
 * @说明
 * <pre>

 * </pre>
 *
 * @see Help_TB_PrizeItem#inheritance() 继承体系信息
 *
 */
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate

@javax.persistence.Entity(name="t_prizeItem")
@com.lianjing.sh.processing.info.annotation.GenerateInfoModel
@SuppressWarnings("serial")
@com.lianjing.sh.model.common.annotation.Comment("奖品")
@com.lianjing.sh.processing.info.annotation.InfoComment("奖品")
public class TB_PrizeItem
 extends TBSuper_FileBase
 implements 
	com.lianjing.sh.model.common.stardard.TableModel<Long>,
	java.io.Serializable

{

	
	
	/**
	 * 必须属性赋值接口
	 */
	public static interface MustProperties{
		/** 名称 */
		public String getName();
		/** 文档 */
		public String getFileUrl();
		/** 类型 */
		public String getType();
		/** 原名称 */
		public String getOriginalName();
		/** 大小 */
		public Double getSize();
		/** 抽奖 */
		public bairui.international.model.domain.jpa.TB_Prize getPrize();
		/** 非奖品标志 */
		public Boolean getNoPrizeFlag();
	}
	
	/**
	 * 为必须属性赋值
	 */
	public TB_PrizeItem properties(MustProperties properties) {
		this.setName(properties.getName());
		this.setFileUrl(properties.getFileUrl());
		this.setType(properties.getType());
		this.setOriginalName(properties.getOriginalName());
		this.setSize(properties.getSize());
		this.setPrize(properties.getPrize());
		this.setNoPrizeFlag(properties.getNoPrizeFlag());
		return this;
	}
	
	/**
	 *	必须属性构造函数
	 */
	public TB_PrizeItem(MustProperties properties) {
		this.properties(properties);
	}
	
	
	/**
	 * 可选单属性赋值接口
	 */
	public static interface OptionalSingleProperties{
		/** 名称 */
		public String getPrizeName();
		/** 中奖概率% */
		public Double getRate();
	}
	
	/**
	 * 为可选单属性赋值
	 */
	public TB_PrizeItem properties(OptionalSingleProperties properties) {
		this.setPrizeName(properties.getPrizeName());
		this.setRate(properties.getRate());
		return this;
	}
	
	
	
	public TB_PrizeItem(MustProperties must, OptionalSingleProperties optionalSingle) {
		this.properties(must);
		this.properties(optionalSingle);
	}
	
	/**
	 * 仅当前必须属性赋值接口
	 */
	public static interface CurrentMustProperties{
		/** 抽奖 */
		public bairui.international.model.domain.jpa.TB_Prize getPrize();
		/** 非奖品标志 */
		public Boolean getNoPrizeFlag();
	}
	
	/**
	 * 为仅当前必须属性赋值
	 */
	public TB_PrizeItem properties(CurrentMustProperties properties) {
		this.setPrize(properties.getPrize());
		this.setNoPrizeFlag(properties.getNoPrizeFlag());
		return this;
	}
	
	/**
	 * 仅当前可选单属性赋值接口
	 */
	public static interface CurrentOptionalSingleProperties{
		/** 名称 */
		public String getPrizeName();
		/** 中奖概率% */
		public Double getRate();
	}
	
	/**
	 * 为仅当前可选单属性赋值
	 */
	public TB_PrizeItem properties(CurrentOptionalSingleProperties properties) {
		this.setPrizeName(properties.getPrizeName());
		this.setRate(properties.getRate());
		return this;
	}
	
	public TB_PrizeItem(
		@lombok.NonNull com.lianjing.sh.model.uml.model.file.TBSuper_FileBase bean,
		CurrentMustProperties mustProperties,
		CurrentOptionalSingleProperties optionalProperties
	) {
		this(bean);
		this.properties(mustProperties);
		this.properties(optionalProperties);
	}
	
	public TB_PrizeItem(
		@lombok.NonNull com.lianjing.sh.model.uml.model.file.TBSuper_FileBase bean
	) {
		update(bean);
	}
	
	public TB_PrizeItem update(com.lianjing.sh.model.uml.model.file.TBSuper_FileBase bean){
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		this.setName(bean.getName());
		this.setFileUrl(bean.getFileUrl());
		this.setType(bean.getType());
		this.setOriginalName(bean.getOriginalName());
		this.setSize(bean.getSize());
		return this;
	}
	
	
	/**
	 * 更新属性内部类
	 */
	public abstract class UpdateProperties {
	
		public UpdateProperties() throws Exception {
			Integer orderValue = getOrderValue(TB_PrizeItem.this);
			if(isOverride_getOrderValue){
				TB_PrizeItem.this.setOrderValue(orderValue);
			}
	
			String name = getName(TB_PrizeItem.this);
			if(isOverride_getName){
				TB_PrizeItem.this.setName(name);
			}
	
			String fileUrl = getFileUrl(TB_PrizeItem.this);
			if(isOverride_getFileUrl){
				TB_PrizeItem.this.setFileUrl(fileUrl);
			}
	
			String type = getType(TB_PrizeItem.this);
			if(isOverride_getType){
				TB_PrizeItem.this.setType(type);
			}
	
			String originalName = getOriginalName(TB_PrizeItem.this);
			if(isOverride_getOriginalName){
				TB_PrizeItem.this.setOriginalName(originalName);
			}
	
			Double size = getSize(TB_PrizeItem.this);
			if(isOverride_getSize){
				TB_PrizeItem.this.setSize(size);
			}
	
			String prizeName = getPrizeName(TB_PrizeItem.this);
			if(isOverride_getPrizeName){
				TB_PrizeItem.this.setPrizeName(prizeName);
			}
	
			bairui.international.model.domain.jpa.TB_Prize prize = getPrize(TB_PrizeItem.this);
			if(isOverride_getPrize){
				TB_PrizeItem.this.setPrize(prize);
			}
	
			Double rate = getRate(TB_PrizeItem.this);
			if(isOverride_getRate){
				TB_PrizeItem.this.setRate(rate);
			}
	
			java.util.List<bairui.international.model.domain.jpa.TB_WinPrize> winPrizes = getWinPrizes(TB_PrizeItem.this);
			if(isOverride_getWinPrizes){
				TB_PrizeItem.this.setWinPrizes(winPrizes);
			}
	
			Boolean noPrizeFlag = getNoPrizeFlag(TB_PrizeItem.this);
			if(isOverride_getNoPrizeFlag){
				TB_PrizeItem.this.setNoPrizeFlag(noPrizeFlag);
			}
		}
	
		public TB_PrizeItem up(){
			return TB_PrizeItem.this;
		}
	
		/** 排序值 */
		private boolean isOverride_getOrderValue = true;
		public Integer getOrderValue(TB_PrizeItem it) throws Exception { 
			isOverride_getOrderValue = false; 
			return null;
		}
		/** 名称 */
		private boolean isOverride_getName = true;
		public String getName(TB_PrizeItem it) throws Exception { 
			isOverride_getName = false; 
			return null;
		}
		/** 文档 */
		private boolean isOverride_getFileUrl = true;
		public String getFileUrl(TB_PrizeItem it) throws Exception { 
			isOverride_getFileUrl = false; 
			return null;
		}
		/** 类型 */
		private boolean isOverride_getType = true;
		public String getType(TB_PrizeItem it) throws Exception { 
			isOverride_getType = false; 
			return null;
		}
		/** 原名称 */
		private boolean isOverride_getOriginalName = true;
		public String getOriginalName(TB_PrizeItem it) throws Exception { 
			isOverride_getOriginalName = false; 
			return null;
		}
		/** 大小 */
		private boolean isOverride_getSize = true;
		public Double getSize(TB_PrizeItem it) throws Exception { 
			isOverride_getSize = false; 
			return null;
		}
		/** 名称 */
		private boolean isOverride_getPrizeName = true;
		public String getPrizeName(TB_PrizeItem it) throws Exception { 
			isOverride_getPrizeName = false; 
			return null;
		}
		/** 抽奖 */
		private boolean isOverride_getPrize = true;
		public bairui.international.model.domain.jpa.TB_Prize getPrize(TB_PrizeItem it) throws Exception { 
			isOverride_getPrize = false; 
			return null;
		}
		/** 中奖概率% */
		private boolean isOverride_getRate = true;
		public Double getRate(TB_PrizeItem it) throws Exception { 
			isOverride_getRate = false; 
			return null;
		}
		/** 中奖 */
		private boolean isOverride_getWinPrizes = true;
		public java.util.List<bairui.international.model.domain.jpa.TB_WinPrize> getWinPrizes(TB_PrizeItem it) throws Exception { 
			isOverride_getWinPrizes = false; 
			return null;
		}
		/** 非奖品标志 */
		private boolean isOverride_getNoPrizeFlag = true;
		public Boolean getNoPrizeFlag(TB_PrizeItem it) throws Exception { 
			isOverride_getNoPrizeFlag = false; 
			return null;
		}
	
	}
	
	
	/**
	 * 构造函数
	 */
	public TB_PrizeItem() {
	}
	
	public TB_PrizeItem(
		@lombok.NonNull Long id
	) {
		this.setId(id);
	}
	
	public TB_PrizeItem(
		@lombok.NonNull TB_PrizeItem bean
	) {
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		this.setName(bean.getName());
		this.setFileUrl(bean.getFileUrl());
		this.setType(bean.getType());
		this.setOriginalName(bean.getOriginalName());
		this.setSize(bean.getSize());
		this.setPrizeName(bean.getPrizeName());
		this.setCreator(bean.getCreator());
		this.setLastModifier(bean.getLastModifier());
		this.setPrize(bean.getPrize());
		this.setRate(bean.getRate());
		this.setWinPrizes(bean.getWinPrizes());
		this.setNoPrizeFlag(bean.getNoPrizeFlag());
	}
	
	

	


	/**
	 * 属性
	 */
	@com.lianjing.sh.model.common.annotation.Comment("名称")
	@com.lianjing.sh.processing.info.annotation.InfoComment("名称")
	@javax.persistence.Column(name="prizeName", length=30)
	private String prizeName;

	@com.lianjing.sh.model.common.annotation.Comment("创建者")
	@com.lianjing.sh.processing.info.annotation.InfoComment("创建者")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.JoinColumn(name="creator_id", nullable=false)
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_Admin creator;

	@com.lianjing.sh.model.common.annotation.Comment("最后修改者")
	@com.lianjing.sh.processing.info.annotation.InfoComment("最后修改者")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.JoinColumn(name="lastModifier_id", nullable=false)
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_Admin lastModifier;

	@com.lianjing.sh.model.common.annotation.Comment("抽奖")
	@com.lianjing.sh.processing.info.annotation.InfoComment("抽奖")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_Prize prize;

	@com.lianjing.sh.model.common.annotation.Comment("中奖概率%")
	@com.lianjing.sh.processing.info.annotation.InfoComment("中奖概率%")
	@javax.persistence.Column(name="rate")
	private Double rate;

	@com.lianjing.sh.model.common.annotation.Comment("中奖")
	@com.lianjing.sh.processing.info.annotation.InfoComment("中奖")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.OneToMany(mappedBy="prizeItem")
	private java.util.List<bairui.international.model.domain.jpa.TB_WinPrize> winPrizes;

	@com.lianjing.sh.model.common.annotation.Comment("非奖品标志")
	@com.lianjing.sh.processing.info.annotation.InfoComment("非奖品标志")
	@javax.persistence.Column(name="noPrizeFlag", nullable=false)
	private Boolean noPrizeFlag;

	/** get[名称] */
	public String getPrizeName() {
		return this.prizeName;
	}

	/** get[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin getCreator() {
		return this.creator;
	}

	/** get[最后修改者] */
	public bairui.international.model.domain.jpa.TB_Admin getLastModifier() {
		return this.lastModifier;
	}

	/** get[抽奖] */
	public bairui.international.model.domain.jpa.TB_Prize getPrize() {
		return this.prize;
	}

	/** get[中奖概率%] */
	public Double getRate() {
		return this.rate;
	}

	/** get[中奖] */
	public java.util.List<bairui.international.model.domain.jpa.TB_WinPrize> getWinPrizes() {
		return this.winPrizes;
	}

	/** get[非奖品标志] */
	public Boolean getNoPrizeFlag() {
		return this.noPrizeFlag;
	}

	/** set[名称] */
	public void setPrizeName(String prizeName) {
		this.prizeName = prizeName;
	}

	/** set[创建者] */
	public void setCreator(bairui.international.model.domain.jpa.TB_Admin creator) {
		this.creator = creator;
	}

	/** set[最后修改者] */
	public void setLastModifier(bairui.international.model.domain.jpa.TB_Admin lastModifier) {
		this.lastModifier = lastModifier;
	}

	/** set[抽奖] */
	public void setPrize(bairui.international.model.domain.jpa.TB_Prize prize) {
		this.prize = prize;
	}

	/** set[中奖概率%] */
	public void setRate(Double rate) {
		this.rate = rate;
	}

	/** set[中奖] */
	public void setWinPrizes(java.util.List<bairui.international.model.domain.jpa.TB_WinPrize> winPrizes) {
		this.winPrizes = winPrizes;
	}

	/** set[非奖品标志] */
	public void setNoPrizeFlag(Boolean noPrizeFlag) {
		this.noPrizeFlag = noPrizeFlag;
	}



	public void assignPrize(bairui.international.model.domain.jpa.TB_Prize prize) {
		if(null != prize){
			prize.addPrizeItems(this);
		}
		this.setPrize(prize);
	}
	


	/** add[WinPrizes] */
	public TB_PrizeItem addWinPrizes(bairui.international.model.domain.jpa.TB_WinPrize ... winPrizes){
		if(this.winPrizes == null){
			this.winPrizes = new java.util.ArrayList<>();
		}
		for(bairui.international.model.domain.jpa.TB_WinPrize bean : winPrizes){
			bean.setPrizeItem(this);
			this.winPrizes.add(bean);
		}
		return this;
	}
	
	/** remove[WinPrizes] */
	public TB_PrizeItem removeWinPrizes(bairui.international.model.domain.jpa.TB_WinPrize ... winPrizes){
		if(this.winPrizes == null){
			return this;
		}
		for(bairui.international.model.domain.jpa.TB_WinPrize bean : winPrizes){
			bean.setPrizeItem(null);
			this.winPrizes.remove(bean);
		}
		return this;
	}
	
	/**
	 * contains[WinPrizes]
	 *
	 * 全部输入都包含：返回 true
	 * 输入中有至少有一个不包含：返回 false
	 */
	public boolean containsWinPrizes(bairui.international.model.domain.jpa.TB_WinPrize ... winPrizes){
		if(this.winPrizes == null || winPrizes==null || winPrizes.length<=0){
			return false;
		}
		return this.winPrizes.containsAll(java.util.Arrays.asList(winPrizes));
	}
	

	/** take[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin takeCreator(){
		if(null == this.creator){
			this.creator = new bairui.international.model.domain.jpa.TB_Admin();
		}
		return this.creator;
	}
	
	/** take[最后修改者] */
	public bairui.international.model.domain.jpa.TB_Admin takeLastModifier(){
		if(null == this.lastModifier){
			this.lastModifier = new bairui.international.model.domain.jpa.TB_Admin();
		}
		return this.lastModifier;
	}
	
	/** take[抽奖] */
	public bairui.international.model.domain.jpa.TB_Prize takePrize(){
		if(null == this.prize){
			this.prize = new bairui.international.model.domain.jpa.TB_Prize();
		}
		return this.prize;
	}
	
	/** must[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin mustCreator() {
		return this.creator;
	}
	
	/** must[最后修改者] */
	public bairui.international.model.domain.jpa.TB_Admin mustLastModifier() {
		return this.lastModifier;
	}
	
	/** must[抽奖] */
	public bairui.international.model.domain.jpa.TB_Prize mustPrize() {
		return this.prize;
	}
	
	

	/**
	 * 复写 hashCode
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		return prime * result + ((this.getId() == null) ? 0 : this.getId().hashCode());
	}
	
	/**
	 * 复写 equals
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj){
			return true;
		}
		if (obj == null){
			return false;
		}
		if (getClass() != obj.getClass()){
			return false;
		}
		TB_PrizeItem other = (TB_PrizeItem) obj;
		if (this.getId() == null) {
			return false;
		} else if (!this.getId().equals(other.getId())){
			return false;
		}
		return true;
	}
	

	/**
	 * 用来覆盖toString()的输出
	 */
	@javax.persistence.Transient
	private String toString;
	
	public void setToString(String toString) {
		this.toString = toString;
	}
	
	/**
	 * 复写 toString
	 */
	@Override
	public String toString() {
		if(null != this.toString){
			return this.toString;
		}
		String name = this.getName();
		if(null != name){
			return String.valueOf(name);
		}
		return super.toString();
	}	

	@javax.persistence.PrePersist
	public void prePersist() {
		com.lianjing.sh.web.security.authority.login.LoginUserInfo userInfo = com.lianjing.sh.web.security.authority.login.Util_Login.getInfo();
		Object user = null == userInfo ? null : userInfo.getUser();
		this.setCreateTime(new java.util.Date());
		this.setModifyTime(new java.util.Date());
		this.setCreator((bairui.international.model.domain.jpa.TB_Admin)user);
		this.setLastModifier((bairui.international.model.domain.jpa.TB_Admin)user);
	}
	
	@javax.persistence.PreUpdate
	public void preUpdate() {
		com.lianjing.sh.web.security.authority.login.LoginUserInfo userInfo = com.lianjing.sh.web.security.authority.login.Util_Login.getInfo();
		Object user = null == userInfo ? null : userInfo.getUser();
		this.setModifyTime(new java.util.Date());
		this.setLastModifier((bairui.international.model.domain.jpa.TB_Admin)user);
	}



}
